/*
* @Author: asus
* @Date:   2017-05-16 21:23:04
* @Last Modified by:   asus
* @Last Modified time: 2017-05-31 11:19:07
*/

'use strict';
require(["jquery-1.11.3"],function(){
	$(function(){
	
		//右侧固定栏
		$(".rightDB").each(function(index, el) {
			$(this).mouseenter(function() {
				$(this).children('.rightDN').show();
				$(this).css({
					"background": '#ec3d7c'
				});
			}); 
		});
		$(".rightDB").each(function(index, el) {
			$(this).mouseleave(function() {
				$(this).children('.rightDN').hide();
				$(this).css({
					"background": '#4c4c4c'
				});
			}); 
		});
		$(".right_m").hover(function() {
			$(this).css('background', '#ec3d7c');
		}, function() {
			$(this).css('background', '#4c4c4c');
		});
		//回到顶部
		//alert($(document).scrollTop());
		
		$(document).scroll(function(event) {
			//alert(document.body.scrollTop);
			var e = event || window.event;
			var $a = '<div id="returnTop"><i class = "iconfont">&#xe681;</i><span>top</span></div>';
			$(".right_b").append($a);
			 
			//console.log(document.clientHeight);
			$("#returnTop").click(function(event) {
				 $(document).scrollTop(0);
				
			});
			// if(document.body.scrollTop == 0){
			// 	("#returnTop").css('display', 'none');;
			//  }
		});
		
		//导航条下拉菜单
		$(".header_r>li").each(function(index, el) {
			$(this).hover(function() {
				$(this).find('.header_rs').css('display', 'block');
			}, function() {
				$(this).find('.header_rs').css('display', 'none');
			});
		});
		//搜索框
		var oTxt = document.getElementById("txt");
		var oBtn = document.getElementById("btn");
		oTxt.onkeyup = function(){
			var scri = document.createElement("script");
			scri.src = "https://suggest.taobao.com/sug?&q=" + oTxt.value + "&callback=fn";
			document.getElementsByTagName("head")[0].appendChild(scri);
			box.innerHTML = "";
		}
		//左侧商品tab栏
		$(".navList li").each(function($index,ele){
			$(this).mouseenter(function(event) {
				$(this).children('.navDetail').show();
				$(this).css({
					"background": '#fff',
					"color":"#ec3d7c",
					"width":"192px"
				});
				$(this).children('a').css('color', '#ec3d7c');
			});
		})
		$(".navList li").each(function($index, ele) {
			var $this = $(this);
			$(this).mouseleave(function(event) {
				$(this).children('.navDetail').hide();
				$(this).css({
					"background": '#ec3d7c',
					"color": '#fff',
					"width":"190px"
				});
			$(this).children("a").css('color', '#fff');
			});
		});
		//品牌划过下拉菜单
		$("#logoA").hover(function(){
			$(this).children('b').show();
		},function(){
			$(this).children('b').hide();
		});
	});
		//搜索框函数
		function fn(str){
			var oDiv = document.getElementById("box");
			var arr = str.result;
			for(var i = 0; i < arr.length; i ++){
			 	var oA = document.createElement("a");
					oA.href = "javascript:;";
			 		oDiv.appendChild(oA);
			 		//var k = i;
			 		for(var j = 0; j < arr[i].length; j++){
			 			oA.innerHTML +=  arr[i][j];
			 		}
			}
		}
})
